
#ifndef __MAP_H__
#define __MAP_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "MapDefine.h"
#include <SolarHashTable.h>

class Field;
class MapInfo;
class Sector;
class GameZone;
class SectorGroup;

typedef util::SolarHashTable<Field *>				FIELD_HASH;
typedef util::SolarHashTable<Field *>::iterator		FIELD_HASH_ITR;

class Map
{
	enum { _MAX_FIELD_IN_MAP_NUM = 10, };
public:
	Map();
	~Map();	
	VOID				Init(		MapInfo * pMapInfo, int iFieldIndex, 
									CMemoryPoolFactory<Field> * pFieldPool, 
									CMemoryPoolFactory<SectorGroup> * pSectorGroupPool, 
									CMemoryPoolFactory<Sector> * pSectorPool );

	VOID				Release(	CMemoryPoolFactory<Field> * pFieldPool, 
									CMemoryPoolFactory<SectorGroup> * pSectorGroupPool,
									CMemoryPoolFactory<Sector> * pSectorPool );

	VOID				Update( DWORD dwDeltaTick );

	CODETYPE			GetMapCode();
	MapInfo *			GetMapInfo();
	BOOL				CheckMapVersion(CODETYPE dwCodeType, DWORD dwCheckSum);

	eZONETYPE			GetZoneType();
	inline VOID			SetGameZone( GameZone * pZone )		{ m_pGameZone = pZone;	}
	inline GameZone *	GetGameZone()						{ return m_pGameZone;	}
	
	inline Field *		GetFieldx( CODETYPE FieldCode )		{ return m_FieldHashTable.GetData( FieldCode );	}
	inline FIELD_HASH *	GetFieldHashTable()					{ return & m_FieldHashTable;	}

	DWORD				GetTotalMonsterNum();

protected:
	VOID				addField( Field * pField );

private:
	GameZone *			m_pGameZone;
	Zone *				m_pZone;
	MapInfo *			m_pMapInfo;
	FIELD_HASH			m_FieldHashTable;
};


#endif //__MAP_H__